package com.hdu.other.dp.maxSubArraySum;

public class lc152 {
    class Solution {
        public int maxProduct(int[] nums) {
             int len = nums.length;
             double[] maxDP = new double[len];
             double[] minDP = new double[len];
             double ans = 0;
             maxDP[0] = nums[0];
             minDP[0] = nums[0];
             ans = nums[0];
             for (int i = 1; i < len; i++)
             {
                 double p1 = maxDP[i - 1] * nums[i];
                 double p2 = minDP[i - 1] * nums[i];
                 double p3 = nums[i];
                 maxDP[i] = Math.max(p1, Math.max(p2, p3));
                 minDP[i] = Math.min(p1, Math.min(p2, p3));
                 ans = Math.max(ans, maxDP[i]);
             }
             return (int)ans;
        }
    }
}
